Skip to content

refactor: migrate pubky images to coil#846

Merged
ben-kaufman merged 7 commits intofeat/pubky-profilefrom
feat/pubky-async-image
Mar 17, 2026
Merged

refactor: migrate pubky images to coil#846
ben-kaufman merged 7 commits intofeat/pubky-profilefrom
feat/pubky-async-image

Conversation

@ovitrif
Copy link
Collaborator

@ovitrif ovitrif commented Mar 13, 2026

Stacked PR on top of:

Migrates pubky image loading from a manual ViewModel + two-tier cache (PubkyImageCache) to Coil 3, simplifying the architecture and reducing custom code.

Description

  • Add Coil 3 dependency (io.coil-kt.coil3:coil-compose:3.2.0)
  • Create PubkyImageFetcher — a Coil Fetcher that handles pubky:// URIs via PubkyService.fetchFile(), including JSON file descriptor indirection
  • Create ImageModule — Hilt module providing a singleton ImageLoader with memory cache (15% app memory) and disk cache (cacheDir/pubky-images/)
  • Replace PubkyImage composable internals: remove PubkyImageViewModel and use Coil's AsyncImage with onSuccess/onError callbacks and a custom ImageOverlay for smooth animated transitions between loading, success, and error states
  • Use GradientCircularProgressIndicator for the loading state spinner
  • Add spring-pop scale animation on image load success via graphicsLayer
  • Remove PubkyImageCache (replaced by Coil's built-in caching)
  • Remove PubkyRepo.fetchImage() / cachedImage() (image loading now handled entirely by Coil)
  • Update PubkyRepo.signOut() to evict pubky images from Coil caches
  • Add unit tests for PubkyImageFetcher (factory filtering, raw data, JSON descriptor following)
  • Update PubkyRepoTest to reflect removed image methods
  • Update docs/pubky.md to document the new architecture

Note: Uses AsyncImage (standard composition) instead of SubcomposeAsyncImage (subcomposition) — Coil docs recommend this for performance in LazyList contexts like the contacts screen.

Preview

coil.mp4

QA Notes

  • Verify pubky profile images load correctly on the contacts and profile screens
  • Verify images are cached (navigate away and back — should load instantly)
  • Verify sign-out clears cached images (sign out, sign in with different account)
  • Verify loading spinner (gradient circular) appears briefly before image loads
  • Verify error fallback icon appears for broken/unreachable URIs

🤖 Generated with Claude Code

@ovitrif ovitrif self-assigned this Mar 13, 2026
@ovitrif ovitrif requested a review from ben-kaufman March 13, 2026 04:03
@claude

This comment has been minimized.

@ovitrif ovitrif added this to the 2.2.0 milestone Mar 13, 2026
@ovitrif ovitrif removed the request for review from ben-kaufman March 13, 2026 04:18
@ovitrif ovitrif force-pushed the feat/pubky-async-image branch from 0a0d9cc to 5f6e98d Compare March 13, 2026 11:08
Copy link
Member

@jvsena42 jvsena42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice refactor!

@claude

This comment has been minimized.

@ovitrif
Copy link
Collaborator Author

ovitrif commented Mar 13, 2026

Very nice refactor!

Thank you!
I still have to go over why Claude picked SubcomposeAsyncImage and let it convince me, the coil docs say it's less performant than the more-common AsyncImage.

Drafting the PR to avoid accidental merges until that's cleared.

@ovitrif ovitrif marked this pull request as draft March 13, 2026 11:49
ovitrif and others added 5 commits March 16, 2026 15:40
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ovitrif ovitrif force-pushed the feat/pubky-async-image branch from 5f6e98d to 6ae1a82 Compare March 16, 2026 14:53
@ovitrif ovitrif marked this pull request as ready for review March 16, 2026 14:53
@ovitrif
Copy link
Collaborator Author

ovitrif commented Mar 16, 2026

@jvsena42 Refactored to use AsyncImage and added previews recorded after the refactor.

@ovitrif ovitrif requested review from ben-kaufman and jvsena42 March 16, 2026 14:54
@ovitrif
Copy link
Collaborator Author

ovitrif commented Mar 16, 2026

requested re-review from @ben-kaufman mainly for double-checking this is OK with latest changes on base branch

ovitrif and others added 2 commits March 16, 2026 16:40
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ben-kaufman ben-kaufman merged commit 0ce5b99 into feat/pubky-profile Mar 17, 2026
18 checks passed
@ben-kaufman ben-kaufman deleted the feat/pubky-async-image branch March 17, 2026 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants